package org.herui.campus.service.exception;

import com.mlnx.common.entity.Response;
import com.mlnx.common.utils.MyLog;
import org.herui.campus.common.exception.ServiceException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * Created by amanda.shan on 2019/7/1.
 */
@ControllerAdvice
@ResponseBody
public class WebExceptionHandle {

    private static MyLog logger = MyLog.getLog(WebExceptionHandle.class);

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(ServiceException.class)
    public Response handleHttpUserException(ServiceException e) {

        logger.error(e.getDescribe());
        return new Response(e.getCode(), e.getDescribe());
    }


}
